package com.example.demo.spring.service;

import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @className: JdbcService
 * @copyright: Copyright (C) 2019-2028, Inc. All rights reserved.
 * @company: 中兴新云.财务云
 * @author: 刘凯
 * @date: 2024/7/5
 * @Description: com.example.demo.spring.service
 */
@Component
public class JdbcService {

    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private JdbcService jdbcService;

    @Transactional
    public void test(){
        jdbcTemplate.execute("insert into t1 values (1,1,1,1,1)");
//        throw new NullPointerException();
//        Object currentProxy = AopContext.currentProxy();
//        System.out.println(currentProxy);
        jdbcService.test1();
    }
    @Transactional(propagation = Propagation.NEVER)
    public void test1(){
        jdbcTemplate.execute("insert into t1 values (2,2,2,2,2)");
//        throw new NullPointerException();
    }
}

